package com.jkgj.skykingkong.tms.web;

import com.jkgj.skykingkong.tms.application.ConsultationService;
import com.jkgj.skykingkong.tms.application.command.ConsultationCommand;
import com.jkgj.skykingkong.tms.application.dto.ConsultationInfo;
import com.jkgj.skykingkong.tms.application.query.ConsultationQuery;
import com.jkgj.skykingkong.tms.facade.ConsultationListServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Created by sunjh
 * @Decription:
 * @Date: Created in 20:04  2017/9/19 0019.
 * @Modified:
 */
@RestController
@RequestMapping("/consultation")
public class ConsultationController {

    @Autowired
    private ConsultationService consultationService;
    @Autowired
    private ConsultationListServer consultationListServer;

    @RequestMapping(value = "/create" , method = RequestMethod.POST,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public void createConsultation(@RequestBody ConsultationCommand consultationCommand){
        consultationService.createConsultation(consultationCommand);
    }


    @RequestMapping(value = "/start" , method = RequestMethod.POST)
    public void startConsultation(@RequestBody ConsultationCommand consultationCommand){
        consultationService.startConsultation(consultationCommand);
    }

    @RequestMapping(value = "/end" , method = RequestMethod.POST)
    public void endConsultation(@RequestBody ConsultationCommand consultationCommand){
        consultationService.endConsultation(consultationCommand);
    }

    @RequestMapping(value = "/list",method = RequestMethod.POST)
    public Page<ConsultationInfo> findConsltationList(Pageable pageable, ConsultationQuery query){
       return consultationListServer.findConsltationList(pageable,query);
    }
}
